<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/css/iconfont.css">
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <title>注册</title>
  </head>
  <body>
    <div class="header_fixed">
        <div class="h_btn_left" onclick="javascript:history.go(-1)" >
          返回
        </div>
        <div class="top-title">
          骚年，注册吧！
        </div>
        <div class="h_btn_right" onclick="javascript:location.href='login'">
          登录
        </div>
    </div>
    <div class="cs_content">
      <div class="login_box">
        <input type="text" id="username" name="" value="" placeholder="账户">
        <input type="password" id="password" name="" value="" placeholder="密码">
        <button type="button" name="button" onclick="register()">注册</button>
      </div>

    </div>
    <script src="js/zepto.js" charset="utf-8"></script>
    <script type="text/javascript">
      function register() {
      var username =  $('#username').val();
      var password =  $('#password').val();

        $.ajax({
            type:'post',
            url:'/register',
            data:{
              name:username,
              password:password,
            },
            dataType:'json',
            success:function(ret){

              if(ret.ret_code ==0){
                alert(ret.ret_msg);
                location.href="/login";

              }else{
                  alert(ret.ret_msg);
              }
            },
            error:function(err){
              // console.log(err);
            }
          })
        }
    </script>
  </body>
</html>
